package com.bright.cwduijie.duijie.service.impl;

import com.bright.cwduijie.duijie.enums.DataApi;
import com.bright.cwduijie.duijie.enums.SJJHBZ;
import com.bright.cwduijie.duijie.pojo.bo.ApiDataCollection;
import com.bright.cwduijie.duijie.pojo.po.FixedAssetsInfoChange;
import com.bright.cwduijie.duijie.pojo.po.FixedAssetsValueChange;
import com.bright.cwduijie.duijie.pojo.query.DuijieQuery;
import com.bright.cwduijie.duijie.repository.FixedAssetsInfoChangeRepository;
import com.bright.cwduijie.duijie.repository.FixedAssetsValueChangeRepository;
import com.bright.cwduijie.duijie.service.AbstractPerThousandApiService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.function.Function;

/**
 * @Author hxj
 * @Date 2024/7/29 14:41
 * @Description
 */

@Component
@RequiredArgsConstructor
@Slf4j
public class ApiFixedAssetsValueChangeServiceImpl extends AbstractPerThousandApiService<FixedAssetsValueChange> {

    private final FixedAssetsValueChangeRepository repo;

    @Override
    public JpaSpecificationExecutor getJpaSpecificationExecutor() {
        return repo;
    }

    @Override
    public DataApi getDataApi() {
        return DataApi.FIXED_ASSETS_VALUE_CHANGE;
    }

    @Override
    public Function<FixedAssetsValueChange, Integer> getIdFunc() {
        return FixedAssetsValueChange::getId;
    }

    @Override
    protected void getData(ApiDataCollection apiDataCollection, DuijieQuery duijieQuery) {
//        List<FixedAssetsValueChange> dataList =
//                repo.getBySjjhbzAndZtDataKey(SJJHBZ.WAITING.getValue(), duijieQuery.getZtDataKey());
//        dataList.addAll(repo.getBySjjhbzAndZtDataKey(SJJHBZ.ERROR.getValue(), duijieQuery.getZtDataKey()));
        apiDataCollection.setFixedAssetsValueChanges(getNeedDuijieData(duijieQuery));
    }

    @Override
    public Function<FixedAssetsValueChange, String> getDataKeyFunc() {
        return FixedAssetsValueChange::getDATA_KEY;
    }

    @Override
    public Function<ApiDataCollection, List<FixedAssetsValueChange>> getDataFunc() {
        return ApiDataCollection::getFixedAssetsValueChanges;
    }

//    @Override
//    protected List<FixedAssetsValueChange> getNeedDeleteData(DuijieQuery duijieQuery) {
//        return null;
//    }

    @Override
    protected DataApi getDeleteDataApi() {
        return null;
    }
}
